{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 测试集验证以及准确率和召回率"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "from collections import defaultdict\n",
    "import _pickle as cPickle"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user_id</th>\n",
       "      <th>location</th>\n",
       "      <th>age</th>\n",
       "      <th>item_id</th>\n",
       "      <th>rating</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>109815</th>\n",
       "      <td>27462</td>\n",
       "      <td>usa</td>\n",
       "      <td>0</td>\n",
       "      <td>1587492695</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>561365</th>\n",
       "      <td>137190</td>\n",
       "      <td>france</td>\n",
       "      <td>3</td>\n",
       "      <td>0552997234</td>\n",
       "      <td>8.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>182846</th>\n",
       "      <td>42721</td>\n",
       "      <td>canada</td>\n",
       "      <td>3</td>\n",
       "      <td>0671024108</td>\n",
       "      <td>8.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>854053</th>\n",
       "      <td>208829</td>\n",
       "      <td>canada</td>\n",
       "      <td>0</td>\n",
       "      <td>0140503897</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>559009</th>\n",
       "      <td>136348</td>\n",
       "      <td>usa</td>\n",
       "      <td>4</td>\n",
       "      <td>0807220299</td>\n",
       "      <td>9.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        user_id location  age     item_id  rating\n",
       "109815    27462      usa    0  1587492695     0.0\n",
       "561365   137190   france    3  0552997234     8.0\n",
       "182846    42721   canada    3  0671024108     8.0\n",
       "854053   208829   canada    0  0140503897     0.0\n",
       "559009   136348      usa    4  0807220299     9.0"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_data=cPickle.load(\n",
    "    open('./data/test_data.pkl','rb'))\n",
    "test_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 344931 entries, 109815 to 473432\n",
      "Data columns (total 5 columns):\n",
      " #   Column    Non-Null Count   Dtype  \n",
      "---  ------    --------------   -----  \n",
      " 0   user_id   344931 non-null  int64  \n",
      " 1   location  344931 non-null  object \n",
      " 2   age       344931 non-null  int32  \n",
      " 3   item_id   344931 non-null  object \n",
      " 4   rating    344931 non-null  float64\n",
      "dtypes: float64(1), int32(1), int64(1), object(2)\n",
      "memory usage: 14.5+ MB\n"
     ]
    }
   ],
   "source": [
    "test_data.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3    2069\n",
       "0    1321\n",
       "4     225\n",
       "2      26\n",
       "1      24\n",
       "Name: age, dtype: int64"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_data[test_data['location']=='italy']['age'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_data['rating']=test_data['rating'].astype(int)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 344931 entries, 109815 to 473432\n",
      "Data columns (total 5 columns):\n",
      " #   Column    Non-Null Count   Dtype \n",
      "---  ------    --------------   ----- \n",
      " 0   user_id   344931 non-null  int64 \n",
      " 1   location  344931 non-null  object\n",
      " 2   age       344931 non-null  int32 \n",
      " 3   item_id   344931 non-null  object\n",
      " 4   rating    344931 non-null  int32 \n",
      "dtypes: int32(2), int64(1), object(2)\n",
      "memory usage: 13.2+ MB\n"
     ]
    }
   ],
   "source": [
    "test_data.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "defaultdict(dict,\n",
       "            {'australia': {0: [('0099771519', 7.0),\n",
       "               ('1857022424', 5.33),\n",
       "               ('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51)],\n",
       "              1: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              2: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              3: [('0007170866', 6.14),\n",
       "               ('1875989218', 6.0),\n",
       "               ('0860074382', 5.91),\n",
       "               ('0140008535', 5.86),\n",
       "               ('0385335482', 5.71),\n",
       "               ('0553279556', 5.67),\n",
       "               ('0743225082', 5.33),\n",
       "               ('0949206318', 5.17),\n",
       "               ('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76)],\n",
       "              4: [('0091867770', 5.17),\n",
       "               ('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42)],\n",
       "              5: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)]},\n",
       "             'canada': {0: [('0140067477', 7.86),\n",
       "               ('0553250426', 7.12),\n",
       "               ('0060392452', 7.0),\n",
       "               ('0676974791', 6.83),\n",
       "               ('0060959037', 6.38),\n",
       "               ('0771099894', 6.25),\n",
       "               ('0446667900', 6.12),\n",
       "               ('0553375407', 6.0),\n",
       "               ('1550541129', 6.0),\n",
       "               ('0671011375', 6.0),\n",
       "               ('0440224764', 5.88),\n",
       "               ('0385486804', 5.86),\n",
       "               ('0771055706', 5.85),\n",
       "               ('0140096825', 5.83),\n",
       "               ('074343627X', 5.78),\n",
       "               ('067976402X', 5.76),\n",
       "               ('0446530522', 5.67),\n",
       "               ('0451204891', 5.57),\n",
       "               ('0446364193', 5.56),\n",
       "               ('0786868716', 5.5)],\n",
       "              1: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              2: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              3: [('0140042393', 8.33),\n",
       "               ('0552137030', 8.29),\n",
       "               ('0060915544', 8.17),\n",
       "               ('0836220889', 7.83),\n",
       "               ('0836218256', 7.67),\n",
       "               ('0679735771', 7.62),\n",
       "               ('1853260002', 7.5),\n",
       "               ('1573225517', 7.33),\n",
       "               ('0671868691', 7.17),\n",
       "               ('0446532231', 7.15),\n",
       "               ('038542017X', 7.14),\n",
       "               ('0451163524', 7.0),\n",
       "               ('0440224764', 7.0),\n",
       "               ('0771060548', 6.89),\n",
       "               ('0064471047', 6.83),\n",
       "               ('0553287893', 6.83),\n",
       "               ('0451191145', 6.8),\n",
       "               ('0345348036', 6.75),\n",
       "               ('0385486804', 6.71),\n",
       "               ('0441172717', 6.71)],\n",
       "              4: [('0316666343', 7.57),\n",
       "               ('0676974805', 6.0),\n",
       "               ('0440213525', 5.57),\n",
       "               ('0515111279', 5.43),\n",
       "               ('034540288X', 5.29),\n",
       "               ('0676973094', 5.22),\n",
       "               ('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67)],\n",
       "              5: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)]},\n",
       "             'france': {0: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              1: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              2: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              3: [('2070408507', 7.33),\n",
       "               ('2266084372', 7.0),\n",
       "               ('2877302202', 6.8),\n",
       "               ('2253140872', 6.67),\n",
       "               ('2070744833', 6.57),\n",
       "               ('2290302155', 6.33),\n",
       "               ('2253144452', 6.17),\n",
       "               ('2226135022', 6.12),\n",
       "               ('2020306492', 6.0),\n",
       "               ('2290308285', 5.89),\n",
       "               ('2253150711', 5.71),\n",
       "               ('2070414574', 5.43),\n",
       "               ('2264027134', 5.38),\n",
       "               ('2070373630', 5.29),\n",
       "               ('2842051181', 5.2),\n",
       "               ('2266022504', 5.14),\n",
       "               ('0747532745', 5.12),\n",
       "               ('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55)],\n",
       "              4: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              5: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)]},\n",
       "             'germany': {0: [('3423203668', 5.33),\n",
       "               ('3426029553', 5.25),\n",
       "               ('3453007867', 5.17),\n",
       "               ('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52)],\n",
       "              1: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              2: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              3: [('3551551677', 9.5),\n",
       "               ('3551551693', 9.5),\n",
       "               ('3499224615', 7.83),\n",
       "               ('3442727952', 7.43),\n",
       "               ('3518100734', 7.33),\n",
       "               ('3442724686', 7.33),\n",
       "               ('3596215226', 7.3),\n",
       "               ('3423204206', 7.25),\n",
       "               ('3150000017', 7.14),\n",
       "               ('3426612704', 6.89),\n",
       "               ('3423205202', 6.88),\n",
       "               ('3423202947', 6.7),\n",
       "               ('3442442354', 6.67),\n",
       "               ('3551551685', 6.5),\n",
       "               ('340412846X', 6.33),\n",
       "               ('3257061269', 6.17),\n",
       "               ('3518380796', 6.17),\n",
       "               ('3499121581', 6.0),\n",
       "               ('3442421357', 6.0),\n",
       "               ('0552546933', 6.0)],\n",
       "              4: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              5: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)]},\n",
       "             'italy': {0: [('8806142100', 6.33),\n",
       "               ('8826703132', 6.08),\n",
       "               ('884590184X', 6.0),\n",
       "               ('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52)],\n",
       "              1: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              2: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              3: [('8845205118', 7.67),\n",
       "               ('8845915700', 7.17),\n",
       "               ('8817106259', 6.29),\n",
       "               ('8807816067', 6.18),\n",
       "               ('0743222229', 5.86),\n",
       "               ('8807817039', 5.83),\n",
       "               ('8807814684', 5.5),\n",
       "               ('8807812436', 5.33),\n",
       "               ('8845290077', 5.29),\n",
       "               ('8817106100', 5.25),\n",
       "               ('8807816059', 5.1),\n",
       "               ('8804342838', 5.09),\n",
       "               ('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07)],\n",
       "              4: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              5: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)]},\n",
       "             'new zealand': {0: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              1: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              2: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              3: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              4: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              5: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)]},\n",
       "             'other': {0: [('034536676X', 8.17),\n",
       "               ('0439064872', 7.44),\n",
       "               ('0316693251', 7.0),\n",
       "               ('0060008024', 6.86),\n",
       "               ('0385720106', 6.71),\n",
       "               ('0380789019', 6.5),\n",
       "               ('0446608955', 6.5),\n",
       "               ('0385484518', 6.5),\n",
       "               ('0671001795', 6.5),\n",
       "               ('0385335881', 6.5),\n",
       "               ('014100018X', 6.33),\n",
       "               ('044651652X', 6.33),\n",
       "               ('0060987103', 6.33),\n",
       "               ('0440180295', 6.17),\n",
       "               ('0553296981', 6.17),\n",
       "               ('0345339681', 6.17),\n",
       "               ('0345337662', 6.17),\n",
       "               ('0140298479', 6.14),\n",
       "               ('0375707972', 6.0),\n",
       "               ('074343627X', 6.0)],\n",
       "              1: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              2: [('043935806X', 6.33),\n",
       "               ('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42)],\n",
       "              3: [('0553296981', 9.57),\n",
       "               ('0590353403', 8.5),\n",
       "               ('0439139597', 7.22),\n",
       "               ('0842329218', 7.14),\n",
       "               ('0439136350', 7.1),\n",
       "               ('0446310786', 7.0),\n",
       "               ('0312924585', 7.0),\n",
       "               ('0099800403', 6.5),\n",
       "               ('3257228007', 6.33),\n",
       "               ('0446605239', 6.22),\n",
       "               ('0345439104', 6.17),\n",
       "               ('0552134651', 6.14),\n",
       "               ('059035342X', 6.12),\n",
       "               ('0684872153', 6.0),\n",
       "               ('3492045170', 6.0),\n",
       "               ('1400032717', 6.0),\n",
       "               ('0684833395', 5.83),\n",
       "               ('043935806X', 5.82),\n",
       "               ('0679781587', 5.8),\n",
       "               ('0345353145', 5.76)],\n",
       "              4: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              5: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)]},\n",
       "             'portugal': {0: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              1: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              2: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              3: [('038082101X', 9.0),\n",
       "               ('0439139600', 7.33),\n",
       "               ('9505156944', 6.33),\n",
       "               ('0380977788', 5.86),\n",
       "               ('002542730X', 5.75),\n",
       "               ('0460877305', 5.71),\n",
       "               ('0385721234', 5.5),\n",
       "               ('0811214982', 5.3),\n",
       "               ('9722113747', 5.17),\n",
       "               ('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78)],\n",
       "              4: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              5: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)]},\n",
       "             'spain': {0: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              1: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              2: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              3: [('8445071416', 8.83),\n",
       "               ('8420616893', 8.62),\n",
       "               ('950491036X', 8.43),\n",
       "               ('8478886451', 8.4),\n",
       "               ('8408039369', 7.62),\n",
       "               ('8495501074', 7.43),\n",
       "               ('8440627203', 7.17),\n",
       "               ('8445071408', 7.0),\n",
       "               ('0452282152', 7.0),\n",
       "               ('8433914545', 6.62),\n",
       "               ('8423309223', 6.62),\n",
       "               ('8420656747', 6.33),\n",
       "               ('8432206407', 6.17),\n",
       "               ('8401328942', 6.14),\n",
       "               ('8432215333', 6.14),\n",
       "               ('8495616254', 6.0),\n",
       "               ('8472236552', 5.92),\n",
       "               ('8478884459', 5.89),\n",
       "               ('8432215007', 5.86),\n",
       "               ('8483140004', 5.83)],\n",
       "              4: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              5: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)]},\n",
       "             'united kingdom': {0: [('0590660543', 6.33),\n",
       "               ('000649840X', 6.17),\n",
       "               ('0330367358', 6.0),\n",
       "               ('0749395990', 5.67),\n",
       "               ('0099771519', 5.33),\n",
       "               ('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65)],\n",
       "              1: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              2: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)],\n",
       "              3: [('1844262553', 8.35),\n",
       "               ('1857231384', 7.0),\n",
       "               ('0552145424', 6.83),\n",
       "               ('0552134627', 6.67),\n",
       "               ('0440206154', 6.67),\n",
       "               ('0552131059', 6.62),\n",
       "               ('0552142379', 6.5),\n",
       "               ('0140621199', 6.43),\n",
       "               ('0722532938', 6.38),\n",
       "               ('0552149519', 6.2),\n",
       "               ('0380813815', 6.17),\n",
       "               ('0140287248', 6.17),\n",
       "               ('0064407667', 6.12),\n",
       "               ('0349107688', 6.0),\n",
       "               ('0786817070', 6.0),\n",
       "               ('0552134635', 5.9),\n",
       "               ('0140621091', 5.83),\n",
       "               ('0552128481', 5.83),\n",
       "               ('0552137030', 5.83),\n",
       "               ('0552131075', 5.7)],\n",
       "              4: [('1844262553', 8.5),\n",
       "               ('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42)],\n",
       "              5: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)]},\n",
       "             'usa': {0: [('0060256672', 9.33),\n",
       "               ('0971942315', 9.0),\n",
       "               ('0615116426', 8.45),\n",
       "               ('0140309578', 8.33),\n",
       "               ('0316735027', 8.33),\n",
       "               ('0553148001', 8.17),\n",
       "               ('0395977894', 8.1),\n",
       "               ('0877738513', 8.0),\n",
       "               ('0060248025', 8.0),\n",
       "               ('0553351397', 7.57),\n",
       "               ('0618231617', 7.5),\n",
       "               ('0441004520', 7.5),\n",
       "               ('1400032717', 7.5),\n",
       "               ('0689824750', 7.38),\n",
       "               ('0446606421', 7.33),\n",
       "               ('0967370167', 7.29),\n",
       "               ('0385509510', 7.22),\n",
       "               ('0877017883', 7.2),\n",
       "               ('0399140093', 7.14),\n",
       "               ('0060988258', 7.14)],\n",
       "              1: [('0064407667', 9.67),\n",
       "               ('0439139597', 8.33),\n",
       "               ('0439064872', 6.25),\n",
       "               ('059035342X', 5.73),\n",
       "               ('043935806X', 5.43),\n",
       "               ('014038572X', 5.43),\n",
       "               ('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67)],\n",
       "              2: [('0439064864', 9.29),\n",
       "               ('0451191137', 9.0),\n",
       "               ('0590353403', 9.0),\n",
       "               ('0380814021', 8.83),\n",
       "               ('043935806X', 8.38),\n",
       "               ('0802132758', 8.25),\n",
       "               ('0439139597', 8.21),\n",
       "               ('0451523377', 8.0),\n",
       "               ('0671027344', 7.92),\n",
       "               ('0440237688', 7.83),\n",
       "               ('0345342968', 7.64),\n",
       "               ('0440222028', 7.5),\n",
       "               ('0446608955', 7.4),\n",
       "               ('0345339738', 7.38),\n",
       "               ('0385729332', 7.33),\n",
       "               ('0316666343', 7.13),\n",
       "               ('0439136350', 7.12),\n",
       "               ('0440219078', 7.0),\n",
       "               ('0064472272', 7.0),\n",
       "               ('0812550706', 7.0)],\n",
       "              3: [('0066238501', 9.86),\n",
       "               ('0394800389', 9.83),\n",
       "               ('0517693119', 9.83),\n",
       "               ('0920668364', 9.67),\n",
       "               ('0395177111', 9.5),\n",
       "               ('0316779059', 9.0),\n",
       "               ('0060256737', 8.83),\n",
       "               ('0345318587', 8.33),\n",
       "               ('0394800133', 8.25),\n",
       "               ('0786867906', 8.17),\n",
       "               ('0930289234', 8.17),\n",
       "               ('0064471063', 8.11),\n",
       "               ('0811807843', 8.0),\n",
       "               ('0451183940', 7.88),\n",
       "               ('0312423799', 7.67),\n",
       "               ('0060921056', 7.67),\n",
       "               ('0440900794', 7.67),\n",
       "               ('0886775957', 7.57),\n",
       "               ('0671720147', 7.5),\n",
       "               ('1563890119', 7.5)],\n",
       "              4: [('0553377868', 8.86),\n",
       "               ('1579546463', 8.0),\n",
       "               ('0380977311', 7.86),\n",
       "               ('0553379615', 7.83),\n",
       "               ('0446532452', 7.57),\n",
       "               ('0446322180', 7.29),\n",
       "               ('0439064864', 7.22),\n",
       "               ('0451169514', 7.17),\n",
       "               ('0553802461', 7.12),\n",
       "               ('0553268937', 6.83),\n",
       "               ('0553582763', 6.83),\n",
       "               ('0385318782', 6.71),\n",
       "               ('0679457526', 6.7),\n",
       "               ('0140053204', 6.7),\n",
       "               ('0140133488', 6.67),\n",
       "               ('0446611638', 6.64),\n",
       "               ('0679721037', 6.57),\n",
       "               ('0399146008', 6.56),\n",
       "               ('0449006565', 6.5),\n",
       "               ('0345458915', 6.5)],\n",
       "              5: [('1844262553', 8.0),\n",
       "               ('0439139597', 6.72),\n",
       "               ('0439136350', 6.55),\n",
       "               ('0439064864', 6.55),\n",
       "               ('0877017883', 6.19),\n",
       "               ('0618002227', 6.16),\n",
       "               ('0590353403', 6.13),\n",
       "               ('0671027344', 6.07),\n",
       "               ('0385199570', 5.93),\n",
       "               ('0771060548', 5.91),\n",
       "               ('0156528207', 5.78),\n",
       "               ('0618129022', 5.76),\n",
       "               ('0552128481', 5.68),\n",
       "               ('0552131059', 5.67),\n",
       "               ('0811801802', 5.65),\n",
       "               ('0670032379', 5.55),\n",
       "               ('0812550706', 5.52),\n",
       "               ('0375756981', 5.51),\n",
       "               ('0670894605', 5.42),\n",
       "               ('0811825558', 5.36)]}})"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "recommand_data=cPickle.load(\n",
    "    open('./data/recommand_data.pkl','rb'))\n",
    "recommand_data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### 推荐\n",
    "- 先找到train_data和test_data里面每个区域中两个集合都有的用户???\n",
    "    - 忘记是为什么一定要找到这个用户了，给他推荐了，推荐列表也有，自己的打分列表也有\n",
    "    - 准确率和召回率也都可以计算啊？\n",
    "- 对location/age确定的用户，推荐给他recommand_data里面的item_id\n",
    "- 用户自己喜欢的item是rating大于5分的\n",
    "- 用户喜欢与推荐的交集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{0: [('8806142100', 6.33),\n",
       "  ('8826703132', 6.08),\n",
       "  ('884590184X', 6.0),\n",
       "  ('1844262553', 8.0),\n",
       "  ('0439139597', 6.72),\n",
       "  ('0439136350', 6.55),\n",
       "  ('0439064864', 6.55),\n",
       "  ('0877017883', 6.19),\n",
       "  ('0618002227', 6.16),\n",
       "  ('0590353403', 6.13),\n",
       "  ('0671027344', 6.07),\n",
       "  ('0385199570', 5.93),\n",
       "  ('0771060548', 5.91),\n",
       "  ('0156528207', 5.78),\n",
       "  ('0618129022', 5.76),\n",
       "  ('0552128481', 5.68),\n",
       "  ('0552131059', 5.67),\n",
       "  ('0811801802', 5.65),\n",
       "  ('0670032379', 5.55),\n",
       "  ('0812550706', 5.52)],\n",
       " 1: [('1844262553', 8.0),\n",
       "  ('0439139597', 6.72),\n",
       "  ('0439136350', 6.55),\n",
       "  ('0439064864', 6.55),\n",
       "  ('0877017883', 6.19),\n",
       "  ('0618002227', 6.16),\n",
       "  ('0590353403', 6.13),\n",
       "  ('0671027344', 6.07),\n",
       "  ('0385199570', 5.93),\n",
       "  ('0771060548', 5.91),\n",
       "  ('0156528207', 5.78),\n",
       "  ('0618129022', 5.76),\n",
       "  ('0552128481', 5.68),\n",
       "  ('0552131059', 5.67),\n",
       "  ('0811801802', 5.65),\n",
       "  ('0670032379', 5.55),\n",
       "  ('0812550706', 5.52),\n",
       "  ('0375756981', 5.51),\n",
       "  ('0670894605', 5.42),\n",
       "  ('0811825558', 5.36)],\n",
       " 2: [('1844262553', 8.0),\n",
       "  ('0439139597', 6.72),\n",
       "  ('0439136350', 6.55),\n",
       "  ('0439064864', 6.55),\n",
       "  ('0877017883', 6.19),\n",
       "  ('0618002227', 6.16),\n",
       "  ('0590353403', 6.13),\n",
       "  ('0671027344', 6.07),\n",
       "  ('0385199570', 5.93),\n",
       "  ('0771060548', 5.91),\n",
       "  ('0156528207', 5.78),\n",
       "  ('0618129022', 5.76),\n",
       "  ('0552128481', 5.68),\n",
       "  ('0552131059', 5.67),\n",
       "  ('0811801802', 5.65),\n",
       "  ('0670032379', 5.55),\n",
       "  ('0812550706', 5.52),\n",
       "  ('0375756981', 5.51),\n",
       "  ('0670894605', 5.42),\n",
       "  ('0811825558', 5.36)],\n",
       " 3: [('8845205118', 7.67),\n",
       "  ('8845915700', 7.17),\n",
       "  ('8817106259', 6.29),\n",
       "  ('8807816067', 6.18),\n",
       "  ('0743222229', 5.86),\n",
       "  ('8807817039', 5.83),\n",
       "  ('8807814684', 5.5),\n",
       "  ('8807812436', 5.33),\n",
       "  ('8845290077', 5.29),\n",
       "  ('8817106100', 5.25),\n",
       "  ('8807816059', 5.1),\n",
       "  ('8804342838', 5.09),\n",
       "  ('1844262553', 8.0),\n",
       "  ('0439139597', 6.72),\n",
       "  ('0439136350', 6.55),\n",
       "  ('0439064864', 6.55),\n",
       "  ('0877017883', 6.19),\n",
       "  ('0618002227', 6.16),\n",
       "  ('0590353403', 6.13),\n",
       "  ('0671027344', 6.07)],\n",
       " 4: [('1844262553', 8.0),\n",
       "  ('0439139597', 6.72),\n",
       "  ('0439136350', 6.55),\n",
       "  ('0439064864', 6.55),\n",
       "  ('0877017883', 6.19),\n",
       "  ('0618002227', 6.16),\n",
       "  ('0590353403', 6.13),\n",
       "  ('0671027344', 6.07),\n",
       "  ('0385199570', 5.93),\n",
       "  ('0771060548', 5.91),\n",
       "  ('0156528207', 5.78),\n",
       "  ('0618129022', 5.76),\n",
       "  ('0552128481', 5.68),\n",
       "  ('0552131059', 5.67),\n",
       "  ('0811801802', 5.65),\n",
       "  ('0670032379', 5.55),\n",
       "  ('0812550706', 5.52),\n",
       "  ('0375756981', 5.51),\n",
       "  ('0670894605', 5.42),\n",
       "  ('0811825558', 5.36)],\n",
       " 5: [('1844262553', 8.0),\n",
       "  ('0439139597', 6.72),\n",
       "  ('0439136350', 6.55),\n",
       "  ('0439064864', 6.55),\n",
       "  ('0877017883', 6.19),\n",
       "  ('0618002227', 6.16),\n",
       "  ('0590353403', 6.13),\n",
       "  ('0671027344', 6.07),\n",
       "  ('0385199570', 5.93),\n",
       "  ('0771060548', 5.91),\n",
       "  ('0156528207', 5.78),\n",
       "  ('0618129022', 5.76),\n",
       "  ('0552128481', 5.68),\n",
       "  ('0552131059', 5.67),\n",
       "  ('0811801802', 5.65),\n",
       "  ('0670032379', 5.55),\n",
       "  ('0812550706', 5.52),\n",
       "  ('0375756981', 5.51),\n",
       "  ('0670894605', 5.42),\n",
       "  ('0811825558', 5.36)]}"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "recommand_data['italy']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "australia 0\n",
      "australia 1\n",
      "australia 2\n",
      "australia 3\n",
      "australia 4\n",
      "australia 5\n",
      "canada 0\n",
      "canada 1\n",
      "canada 2\n",
      "canada 3\n",
      "canada 4\n",
      "canada 5\n",
      "france 0\n",
      "france 1\n",
      "france 2\n",
      "france 3\n",
      "france 4\n",
      "france 5\n",
      "germany 0\n",
      "germany 1\n",
      "germany 2\n",
      "germany 3\n",
      "germany 4\n",
      "germany 5\n",
      "italy 0\n",
      "italy 1\n",
      "italy 2\n",
      "italy 3\n",
      "italy 4\n",
      "new zealand 0\n",
      "new zealand 1\n",
      "new zealand 2\n",
      "new zealand 3\n",
      "new zealand 4\n",
      "new zealand 5\n",
      "other 0\n",
      "other 1\n",
      "other 2\n",
      "other 3\n",
      "other 4\n",
      "other 5\n",
      "portugal 0\n",
      "portugal 1\n",
      "portugal 2\n",
      "portugal 3\n",
      "portugal 4\n",
      "portugal 5\n",
      "spain 0\n",
      "spain 1\n",
      "spain 2\n",
      "spain 3\n",
      "spain 4\n",
      "spain 5\n",
      "united kingdom 0\n",
      "united kingdom 1\n",
      "united kingdom 2\n",
      "united kingdom 3\n",
      "united kingdom 4\n",
      "united kingdom 5\n",
      "usa 0\n",
      "usa 1\n",
      "usa 2\n",
      "usa 3\n",
      "usa 4\n",
      "usa 5\n"
     ]
    }
   ],
   "source": [
    "union_num=0\n",
    "fav_num=0\n",
    "recom_num=0\n",
    "for location,groupby_location in test_data.groupby('location'):\n",
    "    for age,groupby_location_age in groupby_location.groupby('age'):   \n",
    "        print(location,age)\n",
    "        for user,groupby_location_age_user in groupby_location_age.groupby('user_id'):\n",
    "            user_item=groupby_location_age_user.groupby('item_id')['rating'].mean().sort_values(ascending=False)\n",
    "            fav_data=user_item[user_item>5]\n",
    "            fav_num+=len(fav_data)\n",
    "            recom_data=[recom_data[0] for recom_data in recommand_data[location][age]]\n",
    "            recom_num+=len(recom_data)\n",
    "            union_data=list(set(fav_data)&set(recom_data))\n",
    "            union_num+=len(union_data)\n",
    "# italy的age只有0，1，2，3，4;已经在recommand_data里面补齐了"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "australia 0\n",
      "australia 1\n",
      "australia 2\n",
      "australia 3\n",
      "australia 4\n",
      "australia 5\n",
      "canada 0\n",
      "canada 1\n",
      "canada 2\n",
      "canada 3\n",
      "canada 4\n",
      "canada 5\n",
      "france 0\n",
      "france 1\n",
      "france 2\n",
      "france 3\n",
      "france 4\n",
      "france 5\n",
      "germany 0\n",
      "germany 1\n",
      "germany 2\n",
      "germany 3\n",
      "germany 4\n",
      "germany 5\n",
      "italy 0\n",
      "italy 1\n",
      "italy 2\n",
      "italy 3\n",
      "italy 4\n",
      "new zealand 0\n",
      "new zealand 1\n",
      "new zealand 2\n",
      "new zealand 3\n",
      "new zealand 4\n",
      "new zealand 5\n",
      "other 0\n",
      "other 1\n",
      "other 2\n",
      "other 3\n",
      "other 4\n",
      "other 5\n",
      "portugal 0\n",
      "portugal 1\n",
      "portugal 2\n",
      "portugal 3\n",
      "portugal 4\n",
      "portugal 5\n",
      "spain 0\n",
      "spain 1\n",
      "spain 2\n",
      "spain 3\n",
      "spain 4\n",
      "spain 5\n",
      "united kingdom 0\n",
      "united kingdom 1\n",
      "united kingdom 2\n",
      "united kingdom 3\n",
      "united kingdom 4\n",
      "united kingdom 5\n",
      "usa 0\n",
      "usa 1\n",
      "usa 2\n",
      "usa 3\n",
      "usa 4\n",
      "usa 5\n"
     ]
    }
   ],
   "source": [
    "union_num=0\n",
    "fav_num=0\n",
    "recom_num=0\n",
    "for location,groupby_location in test_data.groupby('location'):\n",
    "    for age,groupby_location_age in groupby_location.groupby('age'):   \n",
    "        print(location,age)\n",
    "        for user,groupby_location_age_user in groupby_location_age.groupby('user_id'):\n",
    "            user_item=groupby_location_age_user.groupby('item_id')['rating'].mean().sort_values(ascending=False)\n",
    "            fav_data=user_item[user_item>5].index\n",
    "            fav_num+=len(fav_data)\n",
    "            recom_data=[recom_data[0] for recom_data in recommand_data[location][age]]\n",
    "            recom_num+=len(recom_data)\n",
    "            union_data=list(set(fav_data)&set(recom_data))\n",
    "            union_num+=len(union_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "435 109217 1066680\n"
     ]
    }
   ],
   "source": [
    "print(union_num,fav_num,recom_num) "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###### 尴尬了，union_num=0\n",
    "- 缓解了尴尬\n",
    "- nuion_num=435"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.0004078074024074699 0.0039828964355365926\n",
      "准确率：0.0408%\n",
      "召回率：0.3983%\n"
     ]
    }
   ],
   "source": [
    "precision=union_num/recom_num\n",
    "recall=union_num/fav_num\n",
    "print(precision,recall)\n",
    "print('准确率：{:.4f}%'.format(precision*100))\n",
    "print('召回率：{:.4f}%'.format(recall*100))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 总结：\n",
    "- union_num=0？？？\n",
    "- 回头找找是哪里出了问题：\n",
    "    - 先开始没有random.seed(123),所以以为和老师的可能真的有差距\n",
    "    - 现在估计问题出在recommend_data本身的逻辑里面了吧\n",
    "    - 最终原因：fav_data取值为：值，而不是index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
